<?php
/**
 * @Name  : StaffSaveRequest.php
 * @Author: yashuai
 */

namespace App\Http\Requests\Org;

use App\Http\Rules\Mobile;
use App\Http\Model\ConstCode;
use Illuminate\Validation\Rule;
use App\Http\Requests\PackingRequest;

class StaffSaveRequest extends PackingRequest
{

    public function rules()
    {
        return [
            'StaffName'    => 'required|max:20',
            'DepartmentID' => 'required|integer',
            'StaffOrder'   => 'integer',
            'Mobile'       => [new Mobile],
            'Position'     => Rule::in(array_keys(ConstCode::$position)),
            'Gender'       => Rule::in(array_keys(ConstCode::$gender)),
            'Email'        => 'email',
            'EnglishName'  => 'alpha_dash',
        ];
    }

    public function messages()
    {
        return [
            'StaffID.required'       => '缺少记录ID参数',
            'StaffID.integer'        => '记录ID参数类型异常',
            'DepartmentID.required'  => '请选择员工所在部门',
            'DepartmentID.integer'   => '部门ID参数类型异常',
            'StaffName.required'     => '请输入员工姓名',
            'StaffName.max'          => '员工姓名长度过长',
            'StaffOrder.integer'     => '排序类型异常',
            'Mobile.mobile'          => '手机号格式错误',
            'Position.in'            => '职务不在范围内',
            'Gender.in'              => '性别不在范围内',
            'Email.email'            => 'Email格式错误',
            'EnglishName.alpha_dash' => '英文名必须是字母、数字、下划线',
        ];
    }

}
